/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bussiness;
import access.*;
import dto.FolderMapping;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
 *
 * @author LW
 */
public class FileBuss {
    public boolean exists(String path){
        FileAccess fac = new FileAccess();
        return fac.exists(path);
    }

    /**
     * write to file
     * @param pathFolderToSave full path
     * @param fileName file name
     * @throws FileNotFoundException
     * @throws IOException
     */
    public boolean writeToFile(String fileName, FolderMapping fm) throws FileNotFoundException, IOException{
        FileAccess fac = new FileAccess();
        return fac.writeToFile(fileName, fm);
    }

    /**
     * return folder path from folder mapping, or null if file not exists
     * @param fileName
     * @return
     * @throws FileNotFoundException
     * @throws IOException
     * @throws ClassNotFoundException
     */
    public String getFolder(String fileName) throws FileNotFoundException, IOException, ClassNotFoundException{
        FileAccess fac = new FileAccess();
        return fac.getFolder(fileName);
    }

    public long fileLength(String filePath) throws FileNotFoundException{
        FileAccess fac = new FileAccess();
        return fac.fileLength(filePath);
    }

    public FolderMapping[] getListFile(){
        FileAccess fac = new FileAccess();
        return fac.getListFile();
    }

    /**
     * delete file in mapping folder
     * @param fileName
     */
    public void deleteFile(String fileName){
        FileAccess fac = new FileAccess();
        fac.deleteFile(fileName);
    }
}
